package com.qk.Dao;

import java.io.InputStream;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.qk.my.wangtobesuper.App;

public class SqlSessionDao {
	private static SqlSession session;
	static {
		String conf = "mybatis_conf.xml";
		InputStream inputStream = App.class.getClassLoader().getResourceAsStream(conf);
		SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(inputStream);
		session = sf.openSession();
	}

	public static SqlSession getSession() {
		return session;
	}

	public static void closeSession() {
		if (session != null)
			session.close();
	}
}
